package symbols;

import lexer.*;
import inter.*;
import java.util.*;

public class Env {
    private Hashtable table;
    protected Env prev;
    private static Env save;
    public Env() { table = new Hashtable(); prev = null; }
    public Env(Env n) {
	table = new Hashtable();
	prev = n;
    }
    public void put(Token w, Id i) {
	table.put(w, i);
    }
    public Id get(Token w) {
	for (Env e = this; e != null; e = e.prev) {
	    Id found = (Id)e.table.get(w);
	    if (found != null)
		return found;
	}
	return null;
    }
    public static void push(Env e) {
	save = e;
    }
    public static Env pop() {
	return save;
    }
}
